package com.srzk.youthleagueback.controller;

import com.srzk.youthleagueback.entity.po.Course;
import com.srzk.youthleagueback.results.Result;
import com.srzk.youthleagueback.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    CourseService courseService;

  /*  @RequestMapping("/update")
    public Result<Course> update(Course course, String teacherName, String className){
        return courseService.update(course,teacherName,className);
    }*/

    @RequestMapping("/getByStudent")
    public Result<List<Course>> getByStudent(String studentName){
        return courseService.getStudentAllCourse(studentName);
    }

    @RequestMapping("/getByTeacher")
    public Result<List<Course>> getAll(String teacherName){
        return courseService.getTeacherAllCourse(teacherName);
    }

  /*  @RequestMapping("/delete")
    public Result<String> delete(String courseName,String teacherName){
        return courseService.deleteCourse(courseName,teacherName);
    }*/

    @RequestMapping("add")
    public Result<String> getByUserName(Course course,String teacherName){
        return courseService.insert(course,teacherName);
    }
}
